package projet_v1;

/**
 * Abstract class representing a common item. That can be a war item, food,
 * ammo, health.
 * 
 * @author Alexis laurent
 * 
 */

abstract public class Item {

    public static final int CODE_HEALTH_ITEM = 0;
    public static final int CODE_WAR_ITEM = 1;
    public static final int CODE_AMMO_ITEM = 2;
    public static final int CODE_FOOD_ITEM = 3;

    // Store the type of the item.
    private int typeItem;

    /**
     * Constructor of the Item class. The integer parameter must corresponds to
     * one of the codes defined above.
     * 
     * @param t
     *            : represents the code of the item.
     */
    public Item(int t) {
        if (t != Item.CODE_HEALTH_ITEM && t != Item.CODE_WAR_ITEM
                && t != Item.CODE_AMMO_ITEM && t != Item.CODE_FOOD_ITEM)
            throw new IllegalArgumentException(
                    "Unknown code item passed to Item's constructor");

        typeItem = t;
    }

    // Accessor
    public int getTypeItem() {
        return typeItem;
    }

    /**
     * To cure or hurt someone, according to the type of the item
     */
    public abstract void use(Character c);

}
